package string;

/**
 * String支持的正则表达式2
 * String replaceAll(String regex,String replacement)
 * 将当前字符串中满足正则表达式regex的部分全部替换为指定字符串replacement
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        /**
         * 将数字部分替换为#NUMBER#
         */
        String str = "abc12423ads^&";
        String regex = "[0-9]+";
        /*String s1=str.replace("abc","s");
        System.out.println("s1:"+s1);*/

        String strRep = str.replaceAll(regex,"#NUMBER#");
        System.out.println(strRep);
        /**
         *和谐用语
         */
        String language = "加微信领福利32143124";
        String regex_wx="(微信)+|[0-9]+";
        String strRep_wx=language.replaceAll(regex_wx,"*");
        System.out.println(strRep_wx);


    }
}
